/**
 * Copyright (c) Software Institude of PKU
 * All rights reserved. 
 * This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 */
package edu.pku.sei.modeler.model.uml.Kernel;
// imports:
import org.w3c.dom.Element;

import edu.pku.sei.gefcommon.descriptor.annotation.MethodProperty;
import edu.pku.sei.modeler.model.common.MetaTypedList;
import edu.pku.sei.modeler.model.xml.XMLUtility;
import edu.pku.sei.modeler.uml.modelHelper.ModelPackage;
import edu.pku.sei.modeler.uml.util.MetaTypedSet;



/**
 * @generated
 *
 */
public class ElementImport extends DirectedRelationship implements IElementImport {
	// attributes
	
	protected VisibilityKind visibility;
	
	protected String alias;
	
	
	
	
	// references
	
	protected MetaTypedList importedElement;
	
	
	
	// getters & setters for attributes
	
	public VisibilityKind getVisibility() {
		return visibility;
	}
	public void setVisibility(VisibilityKind newVisibility) {
		VisibilityKind oldvisibility = visibility;
		visibility = newVisibility;
		firePropertyChange(ModelPackage.ELEMENTIMPORT_VISIBILITY, oldvisibility, newVisibility);
	}
	
	@MethodProperty(
			id = "ELEMENTIMPORT_ALIAS",
			catalog = "General",
			name = ModelPackage.ELEMENTIMPORT_ALIAS,
			setter = "setAlias"
			)
	
	public String getAlias() {
		return alias;
	}
	public void setAlias(String newAlias) {
		String oldalias = alias;
		alias = newAlias;
		firePropertyChange(ModelPackage.ELEMENTIMPORT_ALIAS, oldalias, newAlias);
	}
	
	// getters for references
	
	public MetaTypedList getImportedElement() {
		if(importedElement == null) {
			importedElement = new MetaTypedSet(PackageableElement.class, this, ModelPackage.ELEMENTIMPORT_IMPORTEDELEMENT);
		}
		return importedElement;
	}
	
	// save & load
	public void serialize(Element root) {
		super.serialize(root);
		// attributes
		
		if (this.visibility != null) {
			XMLUtility.xmlInstance.serializeAttribute(root, ModelPackage.ELEMENTIMPORT_VISIBILITY, this.visibility.getEnumName());
		}
		
		
		XMLUtility.xmlInstance.serializeAttribute(root, ModelPackage.ELEMENTIMPORT_ALIAS, alias);
		
		// references
		
		XMLUtility.xmlInstance.serializeNodesNotContain(root, ModelPackage.ELEMENTIMPORT_IMPORTEDELEMENT, importedElement);		
		
	}
	
	public void deSerialize(Element root) {
		super.deSerialize(root);
		// attributes
		
		visibility = new VisibilityKind(XMLUtility.xmlInstance.deSerializeString(root, ModelPackage.ELEMENTIMPORT_VISIBILITY));
		
		alias = XMLUtility.xmlInstance.deSerializeString(root, ModelPackage.ELEMENTIMPORT_ALIAS);
		
		// references
		
		this.getImportedElement().addAll(XMLUtility.xmlInstance.deSerializeNodesNotContain(root, ModelPackage.ELEMENTIMPORT_IMPORTEDELEMENT, this));
		
	}
	
	public void dynamicSet(String featureID, Object value) {
		if(featureID == null || "".equals(featureID)) {
			return;
		}
		// attributes
		
		else if(ModelPackage.ELEMENTIMPORT_VISIBILITY.equals(featureID)) {
			visibility = (VisibilityKind)value;
		}
		
		// references
		
		else if(ModelPackage.ELEMENTIMPORT_IMPORTEDELEMENT.equals(featureID)) {
			getImportedElement().add(value);
		}
		
		else
			super.dynamicSet(featureID, value);
	}
}
 
 
 
 
 